﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace QuanLyPhongKham
{
    /// <summary>
    /// Contains all common functions for this system. 
    /// </summary>
    public class Common
    {
        public static ProcessController NewProcessingDialog()
        {

            ProcessController tk = new ProcessController();
            Thread t = NewThread();
            t.Start(tk);
            return tk;
        }

        public static ProcessController NewProcessingDialog(string message)
        {

            ProcessController tk = new ProcessController();
            Thread t = NewThread(message);

            t.Start(tk);
            return tk;
        }

        public static ProcessController NewProcessingDialog(BaseForm father)
        {

            
            ProcessController tk = new ProcessController(father.Location, father.Size);
            Thread t = NewThread();

            t.Start(tk);
            return tk;
        }

        public static ProcessController NewProcessingDialog(BaseForm father, string message)
        {


            ProcessController tk = new ProcessController(father.Location, father.Size);
            Thread t = NewThread(message);

            t.Start(tk);
            return tk;
        }

        public static ProcessController NewProcessingDialog(BaseRibbonForm father)
        {


            ProcessController tk = new ProcessController(father.Location, father.Size);
            Thread t = new Thread((obj) =>
            {
                
                ProcessDialog f2 = new ProcessDialog((ProcessController)obj);
                f2.ShowDialog();

            });

            t.Start(tk);
            return tk;
        }

        public static ProcessController NewProcessingDialog(BaseRibbonForm father, string message)
        {
            ProcessController tk = new ProcessController(father.Location, father.Size);
            Thread t = NewThread(message);
            t.Start(tk);

            return tk;
        }
  
        private static Thread NewThread(string message)
        {
            Thread t = new Thread((obj) =>
            {
                ProcessDialog f2 = new ProcessDialog((ProcessController)obj);
                f2.MsgLabel.Text = message;
                f2.ShowDialog();
            });
            return t;
        }

        private static Thread NewThread()
        {
            Thread t = new Thread((obj) =>
            {
                ProcessDialog f2 = new ProcessDialog((ProcessController)obj);
                f2.ShowDialog();
            });
            return t;
        }
    }
}
